<?
 require("../inc/functions.php");


function updateUsers($updatearray)
{
	$database = getDB();
	
	$updatearray = arrayEscape($updatearray, $database);

	$statement = "UPDATE Customer_Name SET last_name = '$updatearray[last_name]', first_name = '$updatearray[first_name]', middle_name = '$updatearray[middle_name]'WHERE id = '$updatearray[id]'";

	$results = $database->query($statement);
	
	$error = $database->error;
	
	$database->close();
	
	return $error == "" ? true : array('SQL Error'=> $error);	
}

function getUsersInfo($id)
{
	$database = getDB();

	$statement = "SELECT * FROM Customer_Name WHERE id = '$id'";

	$results = $database->query($statement);

	$database->close();
	
	return $results;
}

function addUsers($array_with_new_info)
{
	$database = getDB();
	
	$array_with_new_info = arrayEscape($array_with_new_info, $database);
	
	
	$statement = "INSERT INTO Customer_Name (last_name, first_name, middle_name) VALUES ('$array_with_new_info[last_name]', '$array_with_new_info[first_name]', '$array_with_new_info[middle_name]')";

	$results = $database->query($statement);
	
	$error = $database->error;

	$database->close();
	
	return $error == "" ? true : array('SQL Error'=> $error);
	
}

function deleteUsers($id)
{
	$database = getDB();

	$statement = "DELETE FROM Customer_Name WHERE id = '$id'";

	$results = $database->query($statement);

	$database->close();
	
	return $results;
}

?>